<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/auth/templates/template.xhtml">
	<ui:define name="pageTitle">Lista de Vendas</ui:define>
	<ui:define name="body">
		<f:view>

			<h:form id="form">

				<h:panelGrid styleClass="center" cellspacing="10px">

					<f:facet name="header">Lista de Vendas</f:facet>

					<h:outputText value="Dados da consulta" styleClass="header3" />

					<h:panelGrid columns="2" cellspacing="10px">

						<h:panelGroup>
							<h:panelGrid columns="2" cellspacing="10px">
								<h:outputText value="Data Inicial" />
								<p:calendar value="#{vendaVSBean.dataInicialPesquisada.time}"
									pattern="dd/MM/yyyy HH:mm" />

								<h:outputText value="Data Final" />
								<p:calendar value="#{vendaVSBean.dataFinalPesquisada.time}"
									pattern="dd/MM/yyyy HH:mm" />
							</h:panelGrid>
						</h:panelGroup>

						<p:commandButton update="@form" value="Consultar"
							style="margin-left:10px;" icon="ui-icon-search" />


						<h:outputText value="Valor Total no Periodo: " />
						<h:outputText value="#{vendaVSBean.valorTotalVendasPesquisadas}">
							<f:convertNumber currencyCode="BRL" type="currency" />
						</h:outputText>
						<h:outputText value="Lucro Sobre Vendas no Periodo: " />
						<h:outputText value="#{vendaVSBean.lucroTotalVendasPesquisadas}">
							<f:convertNumber currencyCode="BRL" type="currency" />
						</h:outputText>
						<h:outputText value="Custos Variáveis Sobre Vendas no Periodo: " />
						<h:outputText
							value="#{vendaVSBean.custosVariaveisSobreVendasPesquisadas}">
							<f:convertNumber currencyCode="BRL" type="currency" />
						</h:outputText>
					</h:panelGrid>
					<p:dataTable id="vendas" value="#{vendaVSBean.vendas}" var="venda"
						emptyMessage="Não existem registros para esta tabela"
						paginator="true" rows="10"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15">
						<p:column headerText="Nº">
							<h:outputText value="#{venda.idVenda}" />
						</p:column>
						<p:column headerText="Data">
							<h:outputText value="#{venda.data.time}">
								<f:convertDateTime dateStyle="medium" type="date" />
							</h:outputText>
						</p:column>
						<p:column headerText="Valor">
							<h:outputText value="#{venda.valor}">
								<f:convertNumber currencyCode="BRL" type="currency" />
							</h:outputText>
						</p:column>
						<p:column headerText="Detalhes"
							style="width:5%;text-align:center;">
							<p:commandButton
								action="consultarvenda?faces-redirect=true&amp;includeViewParams=true"
								icon="ui-icon-search" title="Detalhes">
								<f:setPropertyActionListener value="#{venda}"
									target="#{vendaVSBean.venda}" />
							</p:commandButton>
						</p:column>
					</p:dataTable>
				</h:panelGrid>


			</h:form>
		</f:view>
	</ui:define>
</ui:composition>

</html>